<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-3.3.1.js"></script>

<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/jquery.datetimepicker.css">
	<script src="${pageContext.request.contextPath }/static/js/jquery.datetimepicker.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/ion.calendar.css">
	<script src="${pageContext.request.contextPath }/static/js/moment.min.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/moment.zh-cn.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/ion.calendar.min.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/demo1.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/avgrund.css">
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/avgrund.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/nav.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/addcount.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/demo9.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/menu_sideslide.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/normalize.css" />
	<script type="text/javascript">
		$(function(){
			
		
		$(".start_date").datetimepicker({
            lang:'ch',
            format:'Y-m-d',
            formatDate:'Y-m-d',
            timepicker:false
        });
        $(".end_date").datetimepicker({
            lang:'ch',
            format:'Y-m-d',
            formatDate:'Y-m-d',
            timepicker:false
        });
		});

        $(function(){
            $("#calendar").ionCalendar({
                lang: 'zh-cn',
                format: 'YYYY年M月D日',
                onClick: function(date){
                	var code = "<%=request.getParameter("code")%>";
                	var user=$("#user1").val()
                	if(code==1 ||user!=""){
                	var time=new Date(Date.parse(date.replace('年','-').replace('月','-').replace('日','')))
                    console.log(time)
                    var d=new Date(time);
                    var year=d.getFullYear();
                    var month=change(d.getMonth()+1);
                    var day=change(d.getDate());
                    var time=year+'-'+month+'-'+day;
                    
                    /* alert(time); */
                    openDialog();
                    function change(t){
                        if(t<10){
                            return "0"+t;
                        }else{
                            return t;
                        }
                    }
                   // var user=$("#user1").val()
                   var user="<%=request.getParameter("user")%>"
                    var param_data={
                    	'user':user,
                    	'start_date':time
                    }
                   /*  alert(user); */
                    $.ajax({
                    	type:"POST",
                        url:"${pageContext.request.contextPath }/selectSchedule.action",
                        data:{'param':JSON.stringify(param_data)},
                        dataType:"json",
                        async:false,
                        success:function(data){
                        	console.log(data)
                            if(data != ""){
           						var tbl=""
           						
           						var text3="edit_sch"
                       		 	for(var i=0;i<data.length;i++){
                       		 	var text1="${pageContext.request.contextPath }/deleteSchedule.action?id="+data[i].id
               					var text2="${pageContext.request.contextPath }/SelectOne.action?id="+data[i].id
                       			 tbl+="<p><span>主题</span>：<span>"+data[i].theme+"</span></p><p><span>开始时间</span>：<span>"+data[i].start_date+" "+data[i].start_time+"</span></p><p><span>结束时间</span>：<span>"+data[i].end_date+" "+data[i].end_time+"</span></p><p><span>人员</span>：<span>"+data[i].staff+"</span></p><p><span>说明</span>：<span>"+data[i].instruction +"</span></p>"+"<p><a href='"+text1+"'>删除</a>"+"<a href='"+text2+"' class='"+text3+"'>修改</a></p>"
                       		}  		    	
                 		     $(".detail_content").html(tbl);
                            }else{       
                            	$(".detail_content").html("您没有添加事件");
                            }
                        }
                    });
                }else{
                	alert("您还未登录！");
                }
                }
            
            });
            $(function () {
				$(".ul1").find("li").eq(0).click(function () {
					var code = "<%=request.getParameter("code")%>";
					var user=$("#user1").val()
					
						$(".right_form").show();
                });
				
            });
        });


	</script>
	<script type="text/javascript">

        function openDialog() {
            Avgrund.show( "#default-popup" );
        }

        function closeDialog() {
            Avgrund.hide();
        }

	</script>
	<script type="text/javascript">
	$(function () {
		$(".button_warn").click(function () {
			var code = "<%=request.getParameter("code")%>";
			var user=$("#user1").val()
			if(code==1 || user!=""){
			$(".right_warn").animate({width:'toggle'},300);
			}
			else{
				alert("您还未登录！");
			}
        });
    });
	
	</script> 
	<script type="text/javascript">
		$(function(){
			$(".input_theme").blur(function(){
				$(".formtips").remove();
				if($(this).val()==""){
	                   $(this).after("<span class='formtips'>不能为空</span>")
	               }else{
	                   return;
	               }
			});
			$(".form_submit").click(function(){
				var theme=$(".input_theme").val()
				if(theme==""){
					alert("添加失败");
				}else{
					$(this).prop("type","submit");
				}
			});
		});
	</script>
	<script type="text/javascript">
        $(document).ready(function(){
        	var code = "<%=request.getParameter("code")%>";
        	if(code==0){
        		
                 
                var ch22 = document.getElementById("login");
                ch22.style.visibility="visible";
        	}else if(code==1){
        		
                 
               var ch22 = document.getElementById("login");
                ch22.style.visibility="hidden";
                
               
        	}
        	$("#pt").click(function(){
        	    var name="<%=request.getParameter("user")%>";
        	    location.href="pingtu.jsp?code=1&user="+name;
        	});
        	
          
        	
        });
    </script>
    <script type="text/javascript">
    	$(function(){
    		$(".form_reset").click(function(){
    			location.href="backtime.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
    		});
    	});
    
    </script>
    <script type="text/javascript">
    $(function () {
    	$("#showdt").click(function(){
			if($("#info").css("display")=="none"){
				var user="<%=request.getParameter("user")%>";
				
				$.ajax({        			
        			type:"GET",
        		    url:"/Schedule/findPerson.action",
        		    contentType:"application/json;charset=utf-8",  
        		    //我们使用 JSON.stringify() 方法处理json，将其转换为字符串；
        		    data:{
        		    	'user':user
        		    },
        		    dataType:"json",
        		    async:false,
        		    success:function(result){
        		   
        		    	 if(result.code==1){
        		    		
        		    		 var data=result.data;
        		    			        		    		  		    	
//         		    	 $("#da1").val(data.user);
                 		 $("#da3").val(data.name);
                 		 $("#da4").val(data.phone);
                 		 $("#da5").val(data.address);
                 		 
                 		     
        		    	 }else if(result.code==-1){
        		    		 alert("获取用户失败");
        		    	 }      		    	
        		    }        		    
        		});   
				
				$("#info").show();
				
				
			}else{
				$("#info").hide();
			}
		});
		
		$("#save").click(function(){
			
			var user="<%=request.getParameter("user") %>";
     		var name= $("#da3").val();
     		var phone= $("#da4").val();
     		var address=$("#da5").val();
     		
     		var param_data1={                				
  					'user':user,              				
  					'name':name,
    				'phone':phone,
    				'address':address
      	  }
      	  console.log(JSON.stringify(param_data1));
          
          $.ajax({        			
  			type:"GET",
  		    url:"/Schedule/updatePerson.action",
  		    contentType:"application/json;charset=utf-8",  
  		    //我们使用 JSON.stringify() 方法处理json，将其转换为字符串；
  		    data:{'param':JSON.stringify(param_data1)},
  		    dataType:"json",
  		    async:false,
  		    success:function(result){
  		    	 //var  data=JSON.parse(result);//转换成json对象
  		    	 if(result.code==1){
  		    		alert("修改成功");
  		    	 }else{
  		    		 alert("修改失败");
  		    	 }      		    	
  		    }        		    
  		}); //ajax
          
          
		});//save
	});
    </script>
<title>时间安排</title>
</head>
<body>
<div class="container">
			<div class="menu-wrap">
				<p class="pp">
					当前用户:  
					<span style="font-size: 20px" onclick="" id="showdt">&nbsp;&nbsp;&nbsp;<%=request.getParameter("user") %></span>
				</p>
				<div id="info"  style="height: 150px;display: none;" >

				        <span><font  color="#FFFFFF">&nbsp;密&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;&nbsp;</font><input type="password" id="da2" style="margin-left:15px" value="******"></span>
				        <br>
				        <span><font  color="#FFFFFF">&nbsp;姓&nbsp;&nbsp;&nbsp;名:&nbsp;&nbsp;&nbsp;</font>：<input type="text" id="da3" style="margin-left:15px"></span>
				        <br>
				        <span><font  color="#FFFFFF">&nbsp;手&nbsp;&nbsp;&nbsp;机:&nbsp;&nbsp;&nbsp;</font><input type="text" id="da4" style="margin-left:15px"></span>
				        <br>
				        <span><font  color="#FFFFFF">&nbsp;邮&nbsp;&nbsp;&nbsp;箱:&nbsp;&nbsp;&nbsp;</font><input type="text" id="da5" style="margin-left:15px"></span>
				        <br>
				        
				        
				       <button id="save" style="color:black;margin-left:90px;margin-top:10px">保存</button>

				     </div>
				<div  class="out">
					
					<a id="loginout" data-target="" href="../static/jsp/main.jsp?code=0"><i class="fa fa-fw fa-newspaper-o"></i><span>退出</span></a>
				</div>
				<nav class="menu">
					<div class="icon-list">
						
					</div>
				</nav>
				<button class="close-button" id="close-button">Close Menu</button>
			</div>
			<button class="menu-button" id="open-button">Open Menu</button>
<div class="header" style="background: #373a47">
	
	<div class="header_nav">
		<ul class="ul1">
			<li><a href="../static/jsp/main.jsp?code=<%=request.getParameter("code")%>&user=<%=request.getParameter("user")%>">首页</a></li>
			<li><a href="schedule.jsp?code=<%=request.getParameter("code")%>&user=<%=request.getParameter("user")%>">日程安排</a>
			</li>
			<li><a href="backtime.jsp?code=<%=request.getParameter("code")%>&user=<%=request.getParameter("user")%>">倒计时</a>
			</li>
			<li>益智小游戏
                <ul class="ul2">
                   
                    <li id="pt"><font class="ping" style="color:#fff">拼图</font></li>
                    <li><a href="lianliankan.jsp?code=<%=request.getParameter("code") %>&user=<%=request.getParameter("user") %>" style="margin-left:3px;">连连看</a></li>                
                </ul>
            </li>
            <li><a href="robot.jsp?code=1&user=<%=request.getParameter("user")%>">智能机器人</a></li>
        </ul>
    </div>
    <ul class="register">
        
         
         <li id="message"><a href="message.jsp?code=1&user=<%=request.getParameter("user") %>">消息</a></li>
        <li id="login"><a href="login.jsp">登录</a></li>
    </ul>
</div>
<div class="content" style="background: url(../img/bk.jpg);background-size:cover;">
	<div class="content_left">
		<div class="left_weather">
			<iframe name="weather_inc" src="http://i.tianqi.com/index.php?c=code&id=55"  width="255" height="294" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
		</div>
		<div class="jq22">
			<div id="calendar"></div>
		</div>
	</div>
	<div class="content_right">

		<div class="right_form">
			
			 <form action="${pageContext.request.contextPath }/UpdateCount.action" method="POST">
				<input type="hidden" value="<%=request.getParameter("user") %>" name="user" >
				<input type="hidden" value="${sessionScope.count.id }" name="id">
				<div class="form_theme">
					<label class="label_theme">事件：</label>
					<input type="text" name="event" class="input_theme" placeholder="创建一个事件主题" value="${sessionScope.count.event }">
				</div>
				<div class="form_start">
				<label class="label_start">日期：</label>
				<input type="text" name="end_time" class="start_date" value="${sessionScope.date }" id="end_time">
				<select class="select_hour" name="end_hour" id="end_hour">
					<option value="${sessionScope.hour }" selected="selected">${sessionScope.hour }</option>
					<option value="00">00</option>
					<option value="01">01</option>
					<option value="02">02</option>
					<option value="03">03</option>
					<option value="04">04</option>
					<option value="05">05</option>
					<option value="06">06</option>
					<option value="07">07</option>
					<option value="08">08</option>
					<option value="09">09</option>
					<option value="10">10</option>
					<option value="11">11</option>
					<option value="12">12</option>
					<option value="13">13</option>
					<option value="14">14</option>
					<option value="15">15</option>
					<option value="16">16</option>
					<option value="17">17</option>
					<option value="18">18</option>
					<option value="19">19</option>
					<option value="20">20</option>
					<option value="21">21</option>
					<option value="22">22</option>
					<option value="23">23</option>
					<option value="24">24</option>
				</select><span>:</span>
				<select class="select_minute" name="end_minute" id="end_minute">
					<option value="${sessionScope.hour }" selected="selected">${sessionScope.hour }</option>
					<option value="00">00</option>
					<option value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
					<option value="50">50</option>
					
				</select>
			</div>
				<div class="form_par">
					<label class="label_par">地点：</label>
					<input type="text" name="place" class="input_par" placeholder="添加参与人员" value="${sessionScope.count.place }">
				</div>
				<div class="form_par">
					<label class="label_par">倒计时：</label>
					 <input type="text" name="informtime" class="input_par" readonly="readonly"  value="${sessionScope.count.informtime }" id="informtime">
					<!-- <span id="informtime"></span> -->
				</div>
				
				<div class="form_button">
					<input type="button" value="提交" class="form_submit">
					<input type="button" value="返回" class="form_reset">
				</div> 
			</form>
		</div>
	</div>
	
</div>
<div class="avgrund-cover"></div>
<aside id="default-popup" class="avgrund-popup">
	<h2>今日安排</h2>
	<div class="detail_content" style="height: 196px;overflow: auto" >
		
	</div>
	<button onClick="javascript:closeDialog();" style="float: right;margin-top:5px">Close</button>

</aside>
</div>
	<script type="text/javascript">
	window.onload = function () {
		var informtime=document.getElementById('informtime');
		
		var date=document.getElementById('end_time').value;
		var hour=document.getElementById('end_hour').value;
		var minute=document.getElementById('end_minute').value;
		var time=date+" "+hour+":"+minute;
		console.log(time);
		var nextDate=new Date(time);
		console.log(nextDate);
		window.setInterval(function(){
			 var currentDate = new Date();
	            var currentTime = currentDate.getTime();
	            var nextTime = nextDate.getTime();
	            var allTime = nextTime - currentTime;

	            var allSecond = parseInt(allTime / 1000);

	            // 8.转化   重要
	            var d = size(parseInt(allSecond / 3600 / 24));
	            var h = size(parseInt(allSecond / 3600 % 24));
	            var m = size(parseInt(allSecond / 60 % 60));
	            var s = size(parseInt(allSecond  % 60));
	            informtime.value=d +"天"+ h +"：" + m +"："+ s +"秒";
	            
		},1000);
		function size(num) {
            return num >= 10 ? num : '0' + num;
        }
	}
	</script>
	<script src="${pageContext.request.contextPath }/static/js/classie.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/main.js"></script>
</body>
</html>